home *** CD-ROM | disk | FTP | other *** search
- #define STRICT
-
- // Includes standard Windows
- #include <windows.h>
- #include <windowsx.h>
- #include <time.h>
- #include <stdlib.h>
- #include <malloc.h>
- #include <memory.h>
- #include <stdio.h>
-
- // Includes D3D
- #define D3D_OVERLOADS
- #include <ddraw.h>
- #include <d3d.h>
- #include <d3dx.h>
-
- // Includes utilitaires D3D
- #include "d3dmath.h"
- #include "d3dutil.h"
- #include "D3DEnum.h"
-
- // Ids Resources
- #include "resource.h"
-
- // Constantes
- #include "const.h"
-
- // Types
- #include "types.h"
-
- // Variables globales projet
- #include "vars.h"
-
- // Prototypes fonctions autres modules
- #include "proto.h"
-
- // Macros
- #include "macros.h"
-
- void vSaveDirectX(void)
- {
- int iTriangle, iMtrl;
- static TCHAR sFileName[512];
- FILE* hFile;
-
- #ifndef _AMIGA_
- static TCHAR sInitialDir[512] = "";
- TCHAR sCurrentName[512] = "*.x";
-
- // Récupérer le directory courant
- GetCurrentDirectory(sizeof(sInitialDir), sInitialDir);
-
- // Préparer une structure OPENFILENAME
- OPENFILENAME sOFName = { sizeof(OPENFILENAME), NULL, NULL,
- "Fichiers Scènes DirectX (*.x)\0*.x\0\0",
- NULL, 0, 1, sCurrentName, 512, sFileName, 512,
- sInitialDir, "Ouvrir un fichier scène DirectX", 0, 0, 1,
- ".x", 0, NULL, NULL };
-
- // Choisir un fichier
- if(!GetOpenFileName(&sOFName))
- return;
-
- // Stocker le nom du directory pour le prochain appel
- strcpy(sInitialDir, sCurrentName);
- #else
- strcpy(sFileName, "#?.x");
- if (!FSelect("Ouvrir...", sFileName))
- return;
- #endif
-
- hFile = fopen(sFileName, "w");
- if (!hFile)
- {
- vTrace("Pb ouverture fichier %s", sFileName);
- return;
- }
-
- vTrace("*** Fichier scène ouvert : %s", sFileName);
-
- // Garbage collecter
- vCollect();
-
- // Créer le header
- fprintf(hFile, "xof 0303txt 0032\n\nHeader {\n1;\n0;\n1;\n}\n\n");
-
- // Faire la liste des materials
- for (iMtrl = 0 ; iMtrl < iMtrlFirstAvailable ; iMtrl ++)
- {
- D3DMATERIAL7 *hmtrl = &(Materials[iMtrl].mtrl);
- fprintf(hFile, "Material Material_%d {\n%f, %f, %f, %f;;\n%f;\n%f, %f, %f;;\n%f, %f, %f;;\n}\n\n",
- iMtrl,
- hmtrl -> diffuse.r, hmtrl -> diffuse.g, hmtrl -> diffuse.b, hmtrl -> diffuse.a,
- hmtrl -> power,
- hmtrl -> specular.r, hmtrl -> specular.g, hmtrl -> specular.b,
- hmtrl -> emissive.r, hmtrl -> emissive.g, hmtrl -> emissive.b
- );
- }
-
- // Entête frame
- fprintf(hFile, "Frame __sKulpt {\n");
- fprintf(hFile, "FrameTransformMatrix {\n");
- fprintf(hFile, "1.000000,0.000000,0.000000,0.000000;,\n");
- fprintf(hFile, "0.000000,1.000000,0.000000,0.000000;,\n");
- fprintf(hFile, "0.000000,0.000000,1.000000,0.000000;,\n");
- fprintf(hFile, "0.000000,2.396835,0.000000,1.000000;;\n");
- fprintf(hFile, "}\n\n");
-
- // Entête mesh
- fprintf(hFile, "Mesh __sKulptShape {\n");
-
- // Vertices
- fprintf(hFile, "%d;\n", iVertFirstAvailable);
- for (int iVert = 0 ; iVert < iVertFirstAvailable ; iVert++)
- {
- fprintf(hFile, "%f;%f;%f;",
- Vertices[iVert].vPoint.x, Vertices[iVert].vPoint.y, Vertices[iVert].vPoint.z);
- if (iVert == iVertFirstAvailable - 1)
- fprintf(hFile, ";\n\n");
- else
- fprintf(hFile, ",\n");
- }
-
- // Triangles
- fprintf(hFile, "%d;\n", iTriaFirstAvailable);
- for (iTriangle = 0 ; iTriangle < iTriaFirstAvailable ; iTriangle++)
- {
- fprintf(hFile, "3;%d,%d,%d;",
- Triangles[iTriangle].iSommets[0], Triangles[iTriangle].iSommets[1], Triangles[iTriangle].iSommets[2]);
- if (iTriangle == iTriaFirstAvailable - 1)
- fprintf(hFile, ";\n\n");
- else
- fprintf(hFile, ",\n");
- }
-
- // Mesh Materials
- fprintf(hFile, "MeshMaterialList {\n%d;\n%d;\n", iMtrlFirstAvailable, iTriaFirstAvailable);
- for (iTriangle = 0 ; iTriangle < iTriaFirstAvailable ; iTriangle++)
- {
- fprintf(hFile, "%d", Triangles[iTriangle].iMtrl);
- if (iTriangle == iTriaFirstAvailable - 1)
- fprintf(hFile, ";;\n");
- else
- fprintf(hFile, ",\n");
- }
- for (iMtrl = 0 ; iMtrl < iMtrlFirstAvailable ; iMtrl++)
- fprintf(hFile, "{Material_%d}\n", iMtrl);
- fprintf(hFile, "}\n\n");
-
- // Fin de mesh
- fprintf(hFile, "}\n\n");
-
- // fin de frame
- fprintf(hFile, "}\n\n");
-
- // Animationset
- fprintf(hFile, "AnimationSet skulpt_animset {\n");
- fprintf(hFile, "}\n");
-
-
- fclose(hFile);
- }
-
- void vLoadDirectX(void)
- {
- }
-
-